home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
dsiic2.zip
/
L_COPY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-15
|
1KB
|
38 lines
/* Copyright (c) James L. Pinson 1990,1991 */
/********************** L_COPY.C ***************************/
#include "mydef.h"
#include <string.h>
/*****************************************************************
Usage: void copy (char *from,char *to,int first,int length);
char *from = string to copy from.
char *to = string to copy to.
int first = position within string to start copying.
int length = number of character to copy.
Copies a section of text, beginning at position "first" in
string "from" and copies "length" number to string "to".
(zero based counting, begins at zero not one)
Example: copy (&to "test",1,2);
results: to = "es"
*****************************************************************/
void copy (char *from,char *to,int first,int length)
{
int i;
if ( (first <0) ) return; /* invalid number */
/* if attempt made to copy beyond end of string then adjust*/
if((first+length+1 ) > strlen(from))length=strlen(from)-first ;
for(i=0;i<length;i++)
to[i]= from[(first)+i];
to[i]='\0';
}